/**
 * 函数参数
 */
function foo(x, y = 'world'){
  y = y || 'world'
  console.log(x,y)
}
foo('hello', 0)

// 参数解构
function foo1({x, y=1}){
  console.log(x,y)
}

foo1({x:1,y:2})

// 解构赋值
function ajax(url, {
  body= '',
  method = 'GET',
  headers = {}
} = {}){
  console.log(method)
}

ajax('www.baidu.com',{
  method:'POST'
})

// length
console.log(ajax.length)

// 参数作用域
let x = 1 
function foo2(x, y = x){
  console.log(x, y) // 2 2
}

foo2(2)

let z = 1 
function foo3(y = z){
  let z = 2
  console.log(z, y) // 2 1
}

foo3()
// 函数 name 属性

console.log(foo3)
console.log((new Function).name)

function foo4(x, y){
  console.log(this,x,y)
}

foo4.bind({name:'aqie'})(1,2)
console.log(foo4.bind({}).name)          // bound foo4
console.log((function(){}).bind({}).name)// bound